package practice05;

import java.util.*;

/**
 * @author Administrator
 * @version V1.0
 * @ProjectName:IntelliJ IDEA
 * @PackageName: practice05
 * @ClassName: Main
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @date 2019/12/17 19:57
 * @Copyright 大牛版板所有
 */
public class Main {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        list.add(new Student("张三",20,90.0F));
        list.add(new Student("李四",22,90.0F));
        list.add(new Student("王五",20,95.0F));
        list.add(new Student("赵六",22,100.0F));
        list.add(new Student("田七",26,87.0F));

        Collections.sort(list, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                int result = (int)(o2.getScore() - o1.getScore());
                if(result==0){
                    result = o2.getAge()-o1.getAge();
                }
                return  result;
            }
        });

        for (Student s:list) {
            System.out.println(s.getName()+"\t"+s.getAge()+"\t\t"+s.getScore());
        }
    }
}
